<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>异步加载地图</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  <style>
    body,
    html,
    #container {
      overflow: hidden;
      width: 100%;
      height: 100%;
      margin: 0;
      font-family: "微软雅黑";
    }
  </style>
</head>
<body>
<div id="container"></div>
</body>
</html>
<script>
  function loadJScript() {
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = '//api.map.baidu.com/api?type=webgl&v=1.0&ak=XEBDRroG9bAGjS1Tomqz0pVg74MXZAfu&callback=init';
    document.body.appendChild(script);
  }
  function init() {
    var map = new BMapGL.Map('container'); // 创建Map实例
    var point = new BMapGL.Point(116.404, 39.915); // 创建点坐标
    // var point = new BMapGL.Point(31.150343,121.806286);
    // 31.150343,121.806286
    map.centerAndZoom(point, 12);
    map.enableScrollWheelZoom(); // 启用滚轮放大缩小
    map.setCurrentCity('北京');
  }
  window.onload = loadJScript; // 异步加载地图
</script>
